#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main() {
    std::vector<int> c;
    for (int i = 2; i < 1000; ++i) {
        int a = 1;
        for (int b = 2; b < i / 2; ++b) {
            if (i % b == 0) {
                a = 0;
                break;
            }
        }
        if (a) {
            c.push_back(i);
        }
    }

    std::vector<std::string> num = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
    std::string p;
    std::getline(std::cin, p);
    std::replace(p.begin(), p.end(), '9', '&');
    std::replace(p.begin(), p.end(), '8', '&');
    std::replace(p.begin(), p.end(), '7', '&');
    std::replace(p.begin(), p.end(), '6', '&');
    std::replace(p.begin(), p.end(), '5', '&');
    std::replace(p.begin(), p.end(), '4', '&');
    std::replace(p.begin(), p.end(), '3', '&');
    std::replace(p.begin(), p.end(), '2', '&');
    std::replace(p.begin(), p.end(), '1', '&');
    std::replace(p.begin(), p.end(), '0', '&');

    if (p.find('&') != std::string::npos || std::count(p.begin(), p.end(), ' ') != 2) {
        std::cout << "Wrong input" << std::endl;
    } else {
        std::vector<std::string> d;
        size_t start = 0;
        size_t end = p.find(' ');
        while (end != std::string::npos) {
            d.push_back(p.substr(start, end - start));
            start = end + 1;
            end = p.find(' ', start);
        }
        d.push_back(p.substr(start));

        std::string newStr = "";
        for (const auto& i : d) {
            newStr += std::to_string(std::distance(num.begin(), std::find(num.begin(), num.end(), i)));
        }
        int grate_maks = std::stoi(newStr);

        std::vector<std::pair<int, int>> w;
        for (int i : c) {
            w.push_back(std::make_pair(std::abs(grate_maks - i), i));
        }

        std::sort(w.begin(), w.end());
        std::cout << w[0].second << std::endl;
    }

    return 0;
}
